(function($) {

	function say(msg) {
		if (console) {
			console.log(msg);
		}
	}

	function getApp() {
		return $("h1").attr("data-app");
	}

	function loadIFrame() {
		var url = 'http://localhost:5581/media/cryptofs/apps/usr/palm/applications/';
		url += getApp();
		url += '/?device=pre';
		$("iframe").remove();
		var iframe = '<iframe src="' + url + '"></iframe>';
		$("#container").append(iframe);
	}

	$(function() {
		var s = new io.Socket();
		s.connect();
		s.on('connect', loadIFrame);
		s.on('message', loadIFrame);
	});

	
})(jQuery);
